package com.ruoyi.zikao.service.impl;

import java.util.List;

import com.ruoyi.gaokao.domain.GkCandidateRegistration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.zikao.mapper.ZikaoCandidateRegistrationMapper;
import com.ruoyi.zikao.domain.ZikaoCandidateRegistration;
import com.ruoyi.zikao.service.IZikaoCandidateRegistrationService;

/**
 * 自考考生报名Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-10
 */
@Service
public class ZikaoCandidateRegistrationServiceImpl implements IZikaoCandidateRegistrationService 
{
    @Autowired
    private ZikaoCandidateRegistrationMapper zikaoCandidateRegistrationMapper;

    @Override
    public int upsertzikaoCandidateRegistration(ZikaoCandidateRegistration registration) {
        // 根据身份证号查询已有的记录
        ZikaoCandidateRegistration existing = zikaoCandidateRegistrationMapper.selectZikaoCandidateRegistrationByIdNumber(registration.getIdNumber());
        if (existing != null) {
            //更新
            return zikaoCandidateRegistrationMapper.updateZikaoCandidateRegistration(registration);
        }else {
            // 新增
            return zikaoCandidateRegistrationMapper.insertZikaoCandidateRegistration(registration);
        }
    }
    /**
     * 查询自考考生报名
     * 
     * @param idNumber 自考考生报名主键
     * @return 自考考生报名
     */
    @Override
    public ZikaoCandidateRegistration selectZikaoCandidateRegistrationByIdNumber(String idNumber)
    {
        return zikaoCandidateRegistrationMapper.selectZikaoCandidateRegistrationByIdNumber(idNumber);
    }

    /**
     * 查询自考考生报名列表
     * 
     * @param zikaoCandidateRegistration 自考考生报名
     * @return 自考考生报名
     */
    @Override
    public List<ZikaoCandidateRegistration> selectZikaoCandidateRegistrationList(ZikaoCandidateRegistration zikaoCandidateRegistration)
    {
        return zikaoCandidateRegistrationMapper.selectZikaoCandidateRegistrationList(zikaoCandidateRegistration);
    }

    /**
     * 新增自考考生报名
     * 
     * @param zikaoCandidateRegistration 自考考生报名
     * @return 结果
     */
    @Override
    public int insertZikaoCandidateRegistration(ZikaoCandidateRegistration zikaoCandidateRegistration)
    {
        return zikaoCandidateRegistrationMapper.insertZikaoCandidateRegistration(zikaoCandidateRegistration);
    }

    /**
     * 修改自考考生报名
     * 
     * @param zikaoCandidateRegistration 自考考生报名
     * @return 结果
     */
    @Override
    public int updateZikaoCandidateRegistration(ZikaoCandidateRegistration zikaoCandidateRegistration)
    {
        return zikaoCandidateRegistrationMapper.updateZikaoCandidateRegistration(zikaoCandidateRegistration);
    }

    /**
     * 批量删除自考考生报名
     * 
     * @param idNumbers 需要删除的自考考生报名主键
     * @return 结果
     */
    @Override
    public int deleteZikaoCandidateRegistrationByIdNumbers(String[] idNumbers)
    {
        return zikaoCandidateRegistrationMapper.deleteZikaoCandidateRegistrationByIdNumbers(idNumbers);
    }

    /**
     * 删除自考考生报名信息
     * 
     * @param idNumber 自考考生报名主键
     * @return 结果
     */
    @Override
    public int deleteZikaoCandidateRegistrationByIdNumber(String idNumber)
    {
        return zikaoCandidateRegistrationMapper.deleteZikaoCandidateRegistrationByIdNumber(idNumber);
    }
}
